package com.huatai.datadevelop.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huatai.datadevelop.entity.DecryptionEntity;
import com.huatai.datadevelop.mapper.DecryptionMapper;
import com.huatai.datadevelop.utils.PageUtils;
import com.huatai.datadevelop.utils.Query;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class DecryptionService extends ServiceImpl<DecryptionMapper, DecryptionEntity> {

    /**
     * 分页获取数据
     * @param params
     * @return
     */
    public Object queryPage(Map<String, Object> params) {
        String maskingName = (String) params.get("maskingName");
        IPage<DecryptionEntity> page = this.page(
                new Query<DecryptionEntity>().getPage(params),
                new QueryWrapper<DecryptionEntity>().like(StringUtils.isNotBlank(maskingName), "masking_name", maskingName)
        );
        return new PageUtils(page);
    }

    /**
     * 新增或更新
     * @param entity
     * @return
     */
    public Object decryptionSaveOrUpdate(DecryptionEntity entity) {
        return this.saveOrUpdate(entity);
    }
}
